package com.baosight.xinreport.sql.controller;

import cn.com.v2.common.base.BaseController;
import cn.com.v2.common.domain.AjaxResult;
import com.baosight.xinreport.sql.service.IRunSqlService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/sql")
public class RunSqlController extends BaseController {

    final
    IRunSqlService iRunSqlService;

    public RunSqlController(IRunSqlService iRunSqlService) {
        this.iRunSqlService = iRunSqlService;
    }


    @ApiOperation(value = "runSql", notes = "runSql")
    @GetMapping("/runSql")
    @ResponseBody
    public AjaxResult runSql() {
        String sql = "select * from abcd where  aaaa=#{abcd}";
        Map map = new HashMap();
        map.put("abcd",2222);
        List<Map> list = iRunSqlService.runQuerySql(sql,map);

        return success(list);
    }
}
